package com.ivo.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.ivo.model.Model;

@Entity
@org.hibernate.annotations.Entity(dynamicUpdate=true)
@Table (name = "PDM_D_DEPENDENCY")
public class Dependency extends Model {

	private static final long serialVersionUID = -1411369989548232487L;
	
	private Long dependencyId;
	private MasterInstance masterIntance;
	private TemplateAttribute templateAttribute;
	private MasterInstance refMasterIntance;
	private TemplateAttribute refTemplateAttribute;
	private boolean isTmpl;
		
	public Dependency(){}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "DEPENDENCY_ID")
	public Long getDependencyId() {
		return dependencyId;
	}

	public void setDependencyId(Long dependencyId) {
		this.dependencyId = dependencyId;
	}
	
	@ManyToOne(cascade = {CascadeType.MERGE})
	@JoinColumn(name = "MAST_INS_FK", nullable = true)
	public MasterInstance getMasterIntance() {
		return masterIntance;
	}

	public void setMasterIntance(MasterInstance masterIntance) {
		this.masterIntance = masterIntance;
	}
	
	@ManyToOne(cascade = {CascadeType.MERGE})
	@JoinColumn(name = "TMPL_ATTR_FK")
	public TemplateAttribute getTemplateAttribute() {
		return templateAttribute;
	}

	public void setTemplateAttribute(TemplateAttribute templateAttribute) {
		this.templateAttribute = templateAttribute;
	}
	
	@ManyToOne(cascade = {CascadeType.MERGE})
	@JoinColumn(name = "REF_MAST_INS_FK" , nullable = true)
	public MasterInstance getRefMasterIntance() {
		return refMasterIntance;
	}

	public void setRefMasterIntance(MasterInstance refMasterIntance) {
		this.refMasterIntance = refMasterIntance;
	}
	
	@ManyToOne(cascade = {CascadeType.MERGE})
	@JoinColumn(name = "REF_TMPL_ATTR_FK")
	public TemplateAttribute getRefTemplateAttribute() {
		return refTemplateAttribute;
	}

	public void setRefTemplateAttribute(TemplateAttribute refTemplateAttribute) {
		this.refTemplateAttribute = refTemplateAttribute;
	}
	
	@Column(name = "IS_TMPL")
	public boolean getIsTmpl() {
		return isTmpl;
	}

	public void setIsTmpl(boolean isTmpl) {
		this.isTmpl = isTmpl;
	}

	
}
